COMMON_OBJ = ../common/obj_all/kernel.o ../common/obj_all/timer.o ../common/obj_all/db.o ../common/obj_all/malloc.o \
             ../common/obj_all/showmsg.o ../common/obj_all/utils.o ../common/obj_all/md52.o ../common/obj_all/sql.o \
             ../common/obj_all/zlib.o ../common/obj_all/blowfish.o ../common/obj_all/taskmgr.o

COMMON_H   = ../common/svnversion.h ../common/mmo.h ../common/version.h \
             ../common/kernel.h ../common/timer.h ../common/db.h 
             ../common/showmsg.h ../common/utils.h ../common/md52.h ../common/blowfish.h \
             ../common/zlib.h ../common/sql.h ../common/lua/lua.h ../common/lua/lua.hpp ../common/lua/lualib.h \
             ../common/lua/luaxlib.h ../common/lua/lunar.h ../common/taskmgr.h

LOGIN_OBJ = obj_login/login.o obj_login/account.o obj_login/lobby.o obj_login/login_auth.o obj_login/login_session.o
LOGIN_H   = login.h account.h lobby.h login_auth.h login_session.h

HAVE_MYSQL = @HAVE_MYSQL@

ifeq ($(HAVE_MYSQL),yes)
    ALL_DEPENDS = server
else
    ALL_DEPENDS = needs_mysql
endif

@SET_MAKE@

###########################################################################
.PHONY : all clean help

all: $(ALL_DEPENDS)

clean :
    rm -rf *.o ../../map-server@EXEEXT@
help:


ifeq ($(HAVE_MYSQL),yes)
    @echo "possible targets are 'all' 'clean' 'help'"
else
    @echo "Couldn't find mysql"
    @exit 1
endif
    @echo "'all'   - builds all above targets"
    @echo "'clean' - cleans builds objects"
    @echo "'help'  - outputs this message"

############################################################################

needs_mysql:
    @echo "MySQL not found or disabled by the configure script"
    @exit 1


server: obj_login server-login

obj_login:
    -mkdir obj_login
server-login: $(LOGIN_OBJ) $(COMMON_OBJ) $(COMMON_H) obj_login/socket.o
    @CXX@ @LDFLAGS@ -o ../../login-server@EXEEXT@ $(COMMON_OBJ) obj_login/socket.o $(LOGIN_OBJ) @LIBS@ @MYSQL_LIBS@ @LUA_LIBS@

obj_login/socket.o: ../common/socket.cpp ../common/socket.h
    @CXX@ -DdsTCPSERV @CXXFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<

obj_login/%.o: %.cpp
    @CXX@ -DdsTCPSERV @CXXFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<

